import { setItem, getItem } from '@/utils/storage'

export default {
  namespaced: true,
  state: () => ({
    siderCollapsed: false,
    token: getItem('tokenApp')
  }),
  mutations: {
    setSiderCollapsed(state, collapsed) {
      state.siderCollapsed = collapsed
      setItem('siderCollapsedApp', state.siderCollapsed)
    },
    setToken(state, token) {
      state.token = token
      setItem('tokenApp', state.token)
    }
  },
  actions: {
    setSiderCollapsed ({ commit }, collapsed) {
      commit('setSiderCollapsed', collapsed)
    },
    setToken ({ commit }, token) {
      commit('setToken', token)
    }
  }
}
